<template>
	<view class="goods-details-bar">
		<swiper-bar :height='750' @change-event="changeCurrent">
			<view class="goods-details-num">
				<view class="uni-font-size-lg uni-text-color-inverse">{{current + 1}}</view>
				<view class="uni-font-size-sm uni-text-color-grey">/3</view>
			</view>
		</swiper-bar>
		<!-- 商品信息 -->
		<view class="goods-info-bar uni-bg-color">
			<view class="goods-info-h1 uni-font-size-lg">iPhone手机iPhone手机iPhone手机iPhone手机iPhone手机iPhone手机</view>
			<view class="goods-info-price">
				<view class="discount-price uni-text-color-active uni-font-size-lg">￥1822.22</view>
				<view class="origina-price  uni-text-color-grey">￥2500.22</view>
			</view>
			<view class="goods-info-base uni-font-size-sm uni-text-color-grey">
				<view>销量60{{$Path}}</view>
				<view>库存999</view>
			</view>
		</view>
		<view class="goods-cell-bar">
			<cell-bar title='选择规格' @onClick='onOpen'></cell-bar>
			<cell-bar >
				<view slot='title' class="goods-cell-center">用户评价(2)</view>
			</cell-bar>
		</view>
		<!-- 商品详情 -->
		<view class="goods-describe-bar uni-bg-color">
			<view class="goods-describe-h1">商品详情</view>
			<view class="goods-describe-content"></view>
		</view>		
		<!-- 底部 -->
		<view class="goods-footer-bar uni-bg-color">
			<view class="footer-item-l">
				<view class="footer-item-l footer-item-l-1">
					<icon-bar name='iconkefu' :size='50'></icon-bar>
				</view>
				<view class="footer-item-l footer-item-l-1">
					<icon-bar name='icongouwuche' :size='50'></icon-bar>
				</view>
			</view>
			<view class="footer-item footer-item-center uni-font-size-lg uni-text-color-inverse">加入购物车</view>
			<view class="footer-item footer-item-right uni-font-size-lg uni-text-color-inverse">立即购买</view>
		</view>
		
		<!-- 商品规格选择弹窗 -->
		<uni-popup type='bottom' ref="popup">
			<goods-select></goods-select>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name: 'GoodsDetails',
		title: '商品详情',
		methods: {
			//获取滑块索引
			changeCurrent(event) {
				this.current = event.mp.detail.current
			},
			// 选择规格
			onOpen() {
				this.$refs.popup.open()
			},
			// 商品详情
			getGoodsDetails() {
				const data = { id: this.id}
				this.$Request(this.$API.getGoodsDetails, data).then(res => {
					console.log(res)
					this.data = res
				})
			}
		},
		data() {
			return {
				data: {},
				current: 0,
				show: false,
				id: ''
			};
		},
		mounted() {
			this.getGoodsDetails()
		},
		onLoad(option) {
			console.log(option)
			this.id = option.id
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/uni.scss';
	.goods-details-bar{
		width: 100%;
		padding-bottom: 100upx;
		.goods-details-num{
			position: absolute;
			right: 20upx;
			bottom: 10upx;
			width: 80upx;
			height: 50upx;
			background: rgba(0, 0, 0, 0.4);
			display: flex;
			align-items: center;
			justify-content: center;
			border-radius: 25upx;
		}
		.goods-info-bar{
			width: 100%;
			padding: 10upx 20upx;
			box-sizing: border-box;
			border-top: solid 2upx #ddd;
			.goods-info-price{
				width: 100%;
				margin-top: 20upx;
				display: flex;
				align-items: center;
				.origina-price{
					text-decoration: line-through;
					font-size: 18upx;
					margin-left: 10upx;
				}
			}
			.goods-info-base{
				width: 100%;
				margin-top: 10upx;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
		}
		.goods-cell-bar{
			width: 100%;
			padding-top: 40upx;
			.goods-cell-center{
				font-weight: bold;
			}
		}
		.goods-describe-bar{
			width: 100%;
			margin-top: 20upx;
			.goods-describe-h1{
				height: 80upx;
				padding: 0 20upx;
				box-sizing: border-box;
				font-weight: bold;
				display: flex;
				align-items: center;
			}
			.goods-describe-content{
				width: 100%;
			}
		}
		.goods-footer-bar{
			width: 100%;
			height: 100upx;
			position: fixed;
			left: 0;
			bottom: var(--window-bottom);
			display: flex;
			box-shadow: 2upx 2upx 2upx 2upx rgba(0, 0, 0, 0.2);
			.footer-item{
				flex: 1.5;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.footer-item-l{
				flex: 1;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.footer-item-l-1{
				width: 50%;
				border-right: solid 2upx #eee;
				box-sizing: border-box;
				&:last-child{
					border:none;
				}
			}
			.footer-item-center{
				background: $uni-color-warning;
			}
			.footer-item-right{
				background: $uni-color-primary;
			}
		}
	}
</style>
